import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalBindingPage(Base):
    """
    账户绑定弹窗
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 登录提示标题
        self.login_tip_title_text = (By.XPATH, Personal.RESOURCE_ID.format("confirm_dialog_title"))

        # 登录提示
        self.login_connect_text = (By.XPATH, Personal.RESOURCE_ID.format("confirm_dialog_content"))

        # 确认按钮
        self.login_ok_btn = (By.XPATH, Personal.RESOURCE_ID.format("btn_confirm_sure"))

        # 取消按钮
        self.login_no_btn = (By.XPATH, Personal.RESOURCE_ID.format("btn_confirm_cancel"))

    def get_tip_title(self):
        """
        获得登录页面标题

        :return: 获取元素
        """
        return self.find_element_o(self.login_tip_title_text)

    def get_connect(self):
        """
        获得登录内容

        :return: 获取元素
        """
        return self.find_element_o(self.login_connect_text)

    def click_ok(self):
        """
        点击确认按钮

        :return: None
        """
        self.click_element(self.login_ok_btn)

    def click_no(self):
        """
        点击取消按钮

        :return: None
        """
        self.click_element(self.login_no_btn)

    def is_toast_personal_binding(self):
        """
        是否进入账号绑定页

        :return: bool
        """
        return self.is_display(self.login_tip_title_text)
